package com.uubx.service.impl;

import com.uubx.mapper.CustomerMapper;
import com.uubx.pojo.Customer;
import com.uubx.service.CustomerService;
import com.uubx.vo.CustomerOrderVo;
import com.uubx.vo.CustomerPolicyVo;
import com.uubx.vo.CustomerVo;
import com.uubx.vo.PolicyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public List<Map> queryCustomerByPage(CustomerVo customerVo) {
        return customerMapper.queryCustomerByPage(customerVo);

    }

    @Override
    public List<Map> queryCustomerAll() {
        return customerMapper.queryCustomerAll();
    }

    @Override
    public Customer queryCustomerMessage(Integer id) {
        return customerMapper.queryCustomerMessage(id);
    }

    @Override
    public List<Map> queryCustomerCar(Integer id) {
        return customerMapper.queryCustomerCar(id);
    }

    @Override
    public List<Map> queryCustomerBank(Integer id) {
        return customerMapper.queryCustomerBank(id);
    }

    @Override
    public List<Map> queryCustomerByHolder(CustomerVo customerVo) {
        //customerVo.setHolder("%"+customerVo.getHolder()+"%");
        return customerMapper.queryCustomerByHolder(customerVo);
    }

    @Override
    public List<Map> queryCustomerByPhone(CustomerVo customerVo) {
        return customerMapper.queryCustomerByPhone(customerVo);
    }

    @Override
    public List<Map> queryCustomerByIdcard(CustomerVo customerVo) {
        return customerMapper.queryCustomerByIdcard(customerVo);
    }

    @Override
    public List<Map> queryPolicy(CustomerPolicyVo policyVo) throws ParseException {
        //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        //SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
        //df.parse(policyVo.getStartTime());
        //ParsePosition pos = new ParsePosition(0);
        //policyVo.setStartTime(df.parse(dateString,pos));
        return customerMapper.queryPolicy(policyVo);
    }

    @Override
    public List<Map> queryOrder(CustomerOrderVo customerOrderVo) {
        return customerMapper.queryOrder(customerOrderVo);
    }
}
